goog.provide('lfpug.ui.renderer.TaskRenderer');
goog.require('goog.functions');
goog.require('lfpug.ui.Renderer');
goog.require('lfpug.ui.type.Template');
goog.require('templates.lfpug.ui.component.TaskComponent');



/**
 * @constructor
 * @extends {lfpug.ui.Renderer}
 */
lfpug.ui.renderer.TaskRenderer = function() {
  goog.base(this);
};
goog.inherits(
    lfpug.ui.renderer.TaskRenderer,
    lfpug.ui.Renderer
);
goog.addSingletonGetter(lfpug.ui.renderer.TaskRenderer);


/**
 * Custom CSS Class.
 * @const
 * @type {string}
 */
lfpug.ui.renderer.TaskRenderer.CSS_CLASS =
    goog.getCssName('task-component');


/** @override */
lfpug.ui.renderer.TaskRenderer.prototype.getCssClass =
    goog.functions.constant(
    lfpug.ui.renderer.TaskRenderer.CSS_CLASS);


/**
 * Main template.
 * @const
 * @type {lfpug.ui.type.Template}
 */
lfpug.ui.renderer.TaskRenderer.TEMPLATE =
    /** @type {lfpug.ui.type.Template} */
    (templates.lfpug.ui.component.TaskComponent.Structure);


/**
 * Hours remaining template
 * @const
 * @type {lfpug.ui.type.Template}
 */
lfpug.ui.renderer.TaskRenderer.HOURS_REMAINING_TEMPLATE =
    /** @type {lfpug.ui.type.Template} */
    (templates.lfpug.ui.component.TaskComponent.HoursRemaining);


/**
 * Hours estimated template
 * @const
 * @type {lfpug.ui.type.Template}
 */
lfpug.ui.renderer.TaskRenderer.HOURS_ESTIMATED_TEMPLATE =
    /** @type {lfpug.ui.type.Template} */
    (templates.lfpug.ui.component.TaskComponent.HoursEstimated);


/** @override */
lfpug.ui.renderer.TaskRenderer.prototype.getTemplate =
    goog.functions.constant(
    lfpug.ui.renderer.TaskRenderer.TEMPLATE);


/**
 *
 * @param {lfpug.ui.component.TaskComponent} task The component being targeted.
 * @param {string} color The css class being added.
 */
lfpug.ui.renderer.TaskRenderer.prototype.setRemainingHoursColor =
    function(task, color) {
  var element = task.getElement();
  var subelement = goog.dom.getElementByClass(
      goog.getCssName('hoursRemaining'),
      element
      );
  goog.dom.classes.add(subelement, color);
};


/**
 *
 * @param {lfpug.ui.component.TaskComponent} task The component being targeted.
 * @param {string} color The css class being added.
 */
lfpug.ui.renderer.TaskRenderer.prototype.setEstimatedHoursColor =
    function(task, color) {
  var element = task.getElement();
  var subelement = goog.dom.getElementByClass(
      goog.getCssName('hoursEstimated'),
      element
      );
  goog.dom.classes.add(subelement, color);
};


/**
 * @param {lfpug.ui.component.TaskComponent} task The task component.
 * @return {{Estimated:number}}
 */
lfpug.ui.renderer.TaskRenderer.prototype.getHoursEstimatedObject =
    function(task) {
  var model = task.getModel();
  var o = {};
  o.Estimated = model.getHoursEstimated();
  return o;
};


/**
 * @param {lfpug.ui.component.TaskComponent} task The task component.
 * @return {{Remaining:number}}
 */
lfpug.ui.renderer.TaskRenderer.prototype.getHoursRemainingObject =
    function(task) {
  var model = task.getModel();
  var o = {};
  o.Remaining = model.getHoursRemaining();
  return o;
};


/**
 * @override
 */
lfpug.ui.renderer.TaskRenderer.prototype.getTemplateObject =
    function(task) {
  var object = goog.base(this, 'getTemplateObject', task);
  var model = task.getModel();
  object.Name = model.getName();
  object.Description = model.getDescription();
  object.Remaining = model.getHoursRemaining();
  object.Estimated = model.getHoursEstimated();
  return object;
};


